package com.payment.ktb.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.payment.ktb.R;
import com.payment.ktb.application.MyApplication;
import com.payment.ktb.model.ServiceItemEntity;
import com.payment.ktb.model.SettleOrder;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by admin on 2017/9/21.
 */

public class ServiceAdapter extends BaseAdapter{



    private Context context;
    private List<ServiceItemEntity> listdata;


    public ServiceAdapter(Context context, List<ServiceItemEntity> listdata) {
        this.context = context;
        this.listdata = listdata;
    }

    public ServiceAdapter() {
    }




    @Override
    public int getCount() {
        return listdata.size();
    }

    @Override
    public Object getItem(int position) {
        return listdata.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder viewHolder = null;
            if (convertView == null) {
                viewHolder = new ViewHolder();
                convertView = View.inflate(context,R.layout.adapter_service_item,null);
                viewHolder.iv_service_icon = (ImageView) convertView.findViewById(R.id.iv_service_icon);
                viewHolder.tv_service_title = (TextView) convertView.findViewById(R.id.tv_service_title);
                viewHolder.tv_service_desc = (TextView) convertView.findViewById(R.id.tv_service_desc);
                convertView.setTag(viewHolder);
            }else {
                viewHolder = (ViewHolder) convertView.getTag();
            }

        Picasso.with(context).load(listdata.get(position).getIcon()).fit().into(viewHolder.iv_service_icon);
        viewHolder.tv_service_title.setText(listdata.get(position).getTitle());
        viewHolder.tv_service_desc.setText(listdata.get(position).getDesc());


        return convertView;
    }



    /**
     *
     */
    class ViewHolder {
        ImageView iv_service_icon;
        TextView tv_service_title;
        TextView tv_service_desc;

    }




}
